

package com.example.daxiguaforharmony.manager;

import com.example.daxiguaforharmony.manager.CrossDevicePlayerInterfaceProxy;
import com.harmonyos.app.ICrossDevicePlayerInterface;
import ohos.rpc.IRemoteBroker;
import ohos.rpc.IRemoteObject;
import ohos.rpc.RemoteException;
import ohos.rpc.RemoteObject;
import ohos.rpc.MessageParcel;
import ohos.rpc.MessageOption;

public abstract class CrossDevicePlayerInterfaceStub extends RemoteObject implements CrossDevicePlayerInterface {
    private static final String DESCRIPTOR = "com.harmonyos.app.CrossDevicePlayerInterface";

    private static final int COMMAND_SEND_COMMAND = IRemoteObject.MIN_TRANSACTION_ID;

    private static final int ERR_OK = 0;
    private static final int ERR_RUNTIME_EXCEPTION = -1;

    public CrossDevicePlayerInterfaceStub(
        /* [in] */ String descriptor) {
        super(descriptor);
    }

    @Override
    public IRemoteObject asObject() {
        return this;
    }

    public static ICrossDevicePlayerInterface asInterface(IRemoteObject object) {
        if (object == null) {
            return null;
        }

        ICrossDevicePlayerInterface result = null;
        IRemoteBroker broker = object.queryLocalInterface(DESCRIPTOR);
        if (broker != null) {
            if (broker instanceof ICrossDevicePlayerInterface) {
                result = (ICrossDevicePlayerInterface)broker;
            }
        } else {
            result = new CrossDevicePlayerInterfaceProxy(object);
        }

        return result;
    }

    @Override
    public boolean onRemoteRequest(
        /* [in] */ int code,
        /* [in] */ MessageParcel data,
        /* [out] */ MessageParcel reply,
        /* [in] */ MessageOption option) throws RemoteException {
        String token = data.readInterfaceToken();
        if (!DESCRIPTOR.equals(token)) {
            return false;
        }
        switch (code) {
            case COMMAND_SEND_COMMAND: {
                int command = data.readInt();
                long soundId = data.readLong();
                sendCommand(command, soundId);
                reply.writeNoException();
                return true;
            }
            default:
                return super.onRemoteRequest(code, data, reply, option);
        }
    }
};

